<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('cluster_reports', function (Blueprint $table) {
            $table->id();
            $table->string('name')->nullable(true)->comment('名称');
            $table->decimal('voltage', 8, 2)->nullable(true)->comment('电压');
            $table->decimal('current', 8, 2)->nullable(true)->comment('电流');
            $table->tinyInteger('SOC')->nullable(true);
            $table->tinyInteger('SOH')->nullable(true);
            $table->tinyInteger('temperature')->nullable(true);
            $table->unsignedBigInteger('e_s_cluster_id')->nullable(true)->comment('储能簇id');
            $table->timestamps();
        });
        Schema::create('battery_reports', function (Blueprint $table) {
            $table->id();
            $table->string('name')->nullable(true)->comment('名称');
            $table->decimal('voltage', 8, 2)->nullable(true)->comment('电压');
            $table->decimal('current', 8, 2)->nullable(true)->comment('电流');
            $table->tinyInteger('SOC')->nullable(true);
            $table->tinyInteger('SOH')->nullable(true);
            $table->tinyInteger('temperature')->nullable(true);
            $table->unsignedBigInteger('e_s_battery_id')->nullable(true)->comment('电池包id');
            $table->timestamps();
        });
        Schema::create('battery_cell_reports', function (Blueprint $table) {
            $table->id();
            $table->string('name')->nullable(true)->comment('名称');
            $table->decimal('voltage', 8, 2)->nullable(true)->comment('电压');
            $table->decimal('current', 8, 2)->nullable(true)->comment('电流');
            $table->tinyInteger('SOC')->nullable(true);
            $table->tinyInteger('SOH')->nullable(true);
            $table->tinyInteger('temperature')->nullable(true);
            $table->unsignedBigInteger('e_s_battery_cell_id')->comment('电芯id');
            $table->timestamps();
        });

    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('cluster_reports');
        Schema::dropIfExists('battery_reports');
        Schema::dropIfExists('battery_cell_reports');
    }
};
